<?php
/**
 * Author: liqinglin
 * CreateTime: 2019-1-9 16:48
 * description:
 */

namespace app\admin\model;


class ServiceErrorMessage extends \think\Model
{
    protected $table = 'cn_service_error_message';

    public static function saveErrorMessage($error_message, $service_id)
    {
        foreach ($error_message as $key => $value) {
            $insert_data[] = ['message' => $value['value'], 'service_id' => $service_id, 'is_del' => 0];
        }
        self::where('service_id', $service_id)->update(['is_del' => 1]);
        return self::insertAll($insert_data);
    }

    /**
     * 保存审核拒绝信息
     * @param $service_id
     */
    public static function getErrorMessage($service_id)
    {
        return self::where('service_id', $service_id)
            ->where('is_del', 0)
            ->field('message')
            ->select();
    }

    /**
     * 删除审核拒绝信息
     * @param $service_id
     * @return ServiceErrorMessage
     */
    public static function delErrorMessage($service_id)
    {
        return self::where('service_id', $service_id)->update(['is_del' => 1]);
    }
}